package org.apache.james.mime4j.io;

import java.io.FilterInputStream;
import java.io.IOException;
import java.io.InputStream;

public class CloseShieldInputStream extends FilterInputStream
{
  public CloseShieldInputStream(InputStream paramInputStream)
  {
    super(paramInputStream);
  }

  private void checkIfClosed()
    throws IOException
  {
    if (this.in == null)
      throw new IOException("Stream is closed");
  }

  public int available()
    throws IOException
  {
    checkIfClosed();
    return this.in.available();
  }

  public void close()
    throws IOException
  {
    this.in = null;
  }

  public InputStream getUnderlyingStream()
  {
    return this.in;
  }

  /**
   * @deprecated
   */
  public void mark(int paramInt)
  {
    monitorenter;
    try
    {
      if (this.in != null)
        this.in.mark(paramInt);
      monitorexit;
      return;
    }
    finally
    {
      localObject = finally;
      monitorexit;
      throw localObject;
    }
  }

  public boolean markSupported()
  {
    boolean bool;
    if (this.in == null)
      bool = false;
    while (true)
    {
      return bool;
      bool = this.in.markSupported();
    }
  }

  public int read()
    throws IOException
  {
    checkIfClosed();
    return this.in.read();
  }

  public int read(byte[] paramArrayOfByte)
    throws IOException
  {
    checkIfClosed();
    return this.in.read(paramArrayOfByte);
  }

  public int read(byte[] paramArrayOfByte, int paramInt1, int paramInt2)
    throws IOException
  {
    checkIfClosed();
    return this.in.read(paramArrayOfByte, paramInt1, paramInt2);
  }

  /**
   * @deprecated
   */
  public void reset()
    throws IOException
  {
    monitorenter;
    try
    {
      checkIfClosed();
      this.in.reset();
      monitorexit;
      return;
    }
    finally
    {
      localObject = finally;
      monitorexit;
      throw localObject;
    }
  }

  public long skip(long paramLong)
    throws IOException
  {
    checkIfClosed();
    return this.in.skip(paramLong);
  }
}